package com.noahplat.person.controller;

import com.noahplat.common.utils.Result;
import com.noahplat.person.service.EmergencyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;

/**
 * @ClassName: EmergencyController
 * @Description: 急救卡对外接口
 * @Author 李景星
 * @Date 2021/3/8
 * @Version 1.0
 */
@RestController
@RequestMapping("/api/emergency")
@Validated
public class EmergencyController {

    @Autowired
    private EmergencyService emergencyService;

    /**
     * 获取人员急救卡信息
     * @param pid
     * @return
     */
    @PreAuthorize("hasAuthority('noahplat-service-person:EmergencyController:getEmergency')")
    @GetMapping("/getEmergency")
    public Result getEmergency(@NotNull(message = "人员ID不能为空 ") @Min(value = 1, message = "人员ID不合法") Long pid){
        return emergencyService.getEmergency(pid);
    }
}
